
package com.insigma.business.qrcode.common.converter;


import com.insigma.business.qrcode.job.dto.search.JobRecruitPositionBSearcher;
import com.insigma.business.qrcode.soldier.dto.JobRecruitPositionDTO;
import com.insigma.business.qrcode.soldier.entity.JobRecruitPositionDO;
import com.insigma.business.qrcode.job.dto.request.JobRecruitPositionInsertRequest;
import com.insigma.business.qrcode.job.dto.request.JobRecruitPositionSearchRequest;
import com.insigma.business.qrcode.job.dto.request.JobRecruitPositionUpdateRequest;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class JobRecruitPositionProviderConverter extends AbstractConverter<JobRecruitPositionDTO, JobRecruitPositionDO> {

    private final static JobRecruitPositionProviderConverter jobRecruitPositionConverter = new JobRecruitPositionProviderConverter();

    private JobRecruitPositionProviderConverter(){}

    
    public static JobRecruitPositionBSearcher convertRequestSO2Searcher(final JobRecruitPositionSearchRequest request){
        final JobRecruitPositionBSearcher jobRecruitPositionBSearcher = new JobRecruitPositionBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,jobRecruitPositionBSearcher);
        return jobRecruitPositionBSearcher;
    }

    
    public static JobRecruitPositionDO convertRequestUO2DO(final JobRecruitPositionUpdateRequest jobRecruitPositionUpdateRequest) {
        final JobRecruitPositionDO jobRecruitPositionDO = new JobRecruitPositionDO();
        BeanUtils.copyProperties(jobRecruitPositionUpdateRequest,jobRecruitPositionDO);
        
        return jobRecruitPositionDO;
    }

    
    public static JobRecruitPositionDO convertRequestIO2DO(final JobRecruitPositionInsertRequest jobRecruitPositionInsertRequest) {
        final JobRecruitPositionDO jobRecruitPositionDO = new JobRecruitPositionDO();
        BeanUtils.copyProperties(jobRecruitPositionInsertRequest,jobRecruitPositionDO);
        return jobRecruitPositionDO;
    }

    
    public static List<JobRecruitPositionDTO> convertResponseDOList2DTOList(final List<JobRecruitPositionDO> jobRecruitPositionDOList){
        return jobRecruitPositionConverter.convertGenericResponseDOList2DTOList(jobRecruitPositionDOList);
    }

    
    public static JobRecruitPositionDTO convertResponseDO2DTO(final JobRecruitPositionDO jobRecruitPositionDO){
        return jobRecruitPositionConverter.convertGenericResponseDO2DTO(jobRecruitPositionDO);
    }

    
    @Override
    protected JobRecruitPositionDTO doConvertResponseDO2DTO(JobRecruitPositionDO jobRecruitPositionDO) {
        final JobRecruitPositionDTO jobRecruitPositionDTO = new JobRecruitPositionDTO();
        try {
            BeanUtils.copyProperties(jobRecruitPositionDO, jobRecruitPositionDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return jobRecruitPositionDTO;
    }

}
